<html>
<head>
<title>Beispiel</title>
</head>
<body>

	<?php
	include_once '../LDB_API/output.php';
	/*
	 bibtexOutput has 2 functions: get_bib_by_id(id) and bibtex_output(infos)
	get_bib_by_id(id) searches for the id in the database, then converts it into an info_struct and passes it on to bibtex_output, which returns a HTML string.
	e.g. get_bib_by_id(id): <body>
	<p>get_bib_by_id(id)<p>
	</body>
	 
	bibtex_output(infos) has one parameter which is an info_struct and returns a HTML string
	e.g. bibtex_output: <body>
	<p>bibtex_output(infos)<p>
	</body>
	 
	*/


	function get_bib_by_id($ref_id) {
	    /* Get infos object containing the reference with ref_id */
	    $ref = ldb_get_by_id($ref_id);
	    if ($ref) {
	        /* pass the info_struct on to bibtex_output */
	        bibtex_output($ref);
	    } else {
	        /* If the id is not in the database */
	        echo "Reference not found.";
	    }
	}

	//include('../../info_struct.php');
	function bibtex_output(infos $info){
	    $output = '@article{graphclass, <br> &nbsp&nbsp&nbsp&nbsp&nbsp';
	    if($info->author != null){
	        $output .= 'author  = {';
	        $output .= $info->author;

	    }
	    if($info->title != null){
	        $output .= '},<br>&nbsp&nbsp&nbsp&nbsp title   = {';
	        $output .= $info->title;
	    }
	    if($info->journal != null){
	        $output .= '},<br>&nbsp&nbsp&nbsp&nbsp journal   = {';
	        $output .= $info->journal;
	    }
	    if($info->volume != null){
	        $output .= '},<br>&nbsp&nbsp&nbsp&nbsp volume   = {';
	        $output .= $info->volume;
	    }
	    if($info->year != null){
	        $output .= '},<br>&nbsp&nbsp&nbsp&nbsp year   = {';
	        $output .= $info->year;
	    }
	    if($info->pages != null){
	        $output .= '},<br>&nbsp&nbsp&nbsp&nbsp pages   = {';
	        $output .= $info->pages;
	    }
	    if($info->number != null){
	        $output .= '},<br>&nbsp&nbsp&nbsp&nbsp number   = {';
	        $output .= $info->number;
	    }
	    if($info->other != null){
	        $output .= '},<br>&nbsp&nbsp&nbsp&nbsp other   = {';
	        $output .= $info->other;
	    }
	    $output.= '}<br>}';
	    echo $output;
	}
	?>

</body>
</html>
